clear all; close all;

samples = Samples('E5a',...
									'~/wnav/snapshots/snapshot_mem_07_e5a.dat');
E5aI_sc = SecondaryPRNCode('E5aI');
NumberOfSamples = floor(E5aI_sc.ChipPeriod/samples.SamplingPeriod);
NumberOfPeriods = 1;
E5aI_pc = PrimaryPRNCode('E5aI', NumberOfSamples, 1); 
E5aQ_pc = PrimaryPRNCode('E5aQ', NumberOfSamples, 1); 
samples.loadSamples(NumberOfSamples*(NumberOfPeriods+1));
for SVID=11:11
	acq = Acquisition('E5a', samples.FrequencyOffset);
	fprintf(1, 'Acquiring E5a PRN %d ... \n', SVID);
	acq.Acquire(samples, NumberOfPeriods, 1e-5, SVID, E5aI_pc, E5aQ_pc);
	if (acq.DetectionStatus)
		fprintf(1, 'E5a PRN %d successfully acquired! \n', SVID);
		figure(SVID); clf;
		[m n] = size(acq.CCF);
		plot((1:m)*samples.SamplingPeriod, abs(acq.CCF),...
				 (1:m)*samples.SamplingPeriod, repmat(acq.Threshold, m, 1));
		xlabel('Time [s]');
		ylabel('CorrOut [-]');
		legend('CCF','Threshold');
	end
end

